#include<bits/stdc++.h>
using namespace std;
int n,m,L,V;
int a[100005];
int d[100005];
int v[100005];
int p[100005];
bool f[10005];
int T;
//int ct[1000005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        bool h=1;
        int cnt=0;
        scanf("%d %d %d %d",&n,&m,&L,&V);
        //cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            scanf("%d %d %d",d+i,v+i,a+i);
            //cin>>d[i]>>v[i]>>a[i];
            if(a[i]<0)
            {
                h=0;
            }
            f[i]=0;
            //ct[i]=0;
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",p+i);
            //cin>>p[i];
        }
        for(int j=1;j<=m;j++)
        {
            for(int i=1;i<=n;i++)
            {
                if(d[i]<=p[j])
                {
                    double vv=sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]));
                    if(vv>V)
                    {
                        if(f[i]==0)
                        {
                            cnt++;
                            f[i]=1;
                        }
                        //cout<<"p:"<<p[j]<<" "<<"i:"<<i<<" "<<"v:"<<vv<<"ct:"<<ct[p[j]]<<endl;
                    }
                }
            }
        }
        printf("%d ",cnt);
        if(h)
        {
            printf("%d",m-1);
        }
        else
        {
            printf("7");
        }
        printf("\n");
        //cout<<T<<endl;
    }
    return 0;
}
